export default function(creatVal, value) {
  if (value.toString().match(/(\d{10})/) || value.toString().match(/(\d{13})/)) {
    const date = new Date();
    if (value.toString().match(/^(\d{10}$)/)) {
      date.setTime(parseInt(value) * 1000);
    } else {
      date.setTime(parseInt(value));
    }
    const rep = [
      [
        'YYYY',
        date => date.getFullYear()
      ],
      [
        'YY',
        date => date.getFullYear().toString().slice(2)
      ],
      [
        'MM',
        date => {
          const month = date.getMonth() + 1;
          return (month < 10 ? '0' : '') + month;
        }
      ],
      [
        'DD',
        date => {
          const day = date.getDate();
          return (day < 10 ? '0' : '') + day;
        }
      ],
      [
        'HH',
        date => {
          const day = date.getHours();
          return (day < 10 ? '0' : '') + day;
        }
      ],
      [
        'hh',
        date => {
          const hour = date.getHours();
          return (hour < 10 ? '0' : '') + hour;
        }
      ],
      [
        'mm',
        date => {
          const minute = date.getMinutes();
          return (minute < 10 ? '0' : '') + minute;
        }
      ], [
        'ss',
        date => {
          const second = date.getSeconds();
          return (second < 10 ? '0' : '') + second;
        }
      ]
    ];
    rep.forEach(item => {
      creatVal = creatVal.replace(item[0], item[1](date));
    });
  }
  return creatVal.toString();
}
